package o;

import android.os.Build.VERSION;
import android.util.Log;
import android.view.View;
import android.widget.PopupWindow;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public final class iw {
    private static boolean ˊ;
    private static Field ˋ;
    private static boolean ˎ;
    private static Method ॱ;

    public static void ˋ(@NonNull PopupWindow popupWindow, @NonNull View view, int i, int i2, int i3) {
        if (VERSION.SDK_INT >= 19) {
            popupWindow.showAsDropDown(view, i, i2, i3);
            return;
        }
        if ((hj.ˎ(i3, ViewCompat.ʼ(view)) & 7) == 5) {
            i -= popupWindow.getWidth() - view.getWidth();
        }
        popupWindow.showAsDropDown(view, i, i2);
    }

    public static void ˎ(@NonNull PopupWindow popupWindow, boolean z) {
        if (VERSION.SDK_INT >= 23) {
            popupWindow.setOverlapAnchor(z);
        } else if (VERSION.SDK_INT >= 21) {
            if (!ˊ) {
                try {
                    ˋ = PopupWindow.class.getDeclaredField("mOverlapAnchor");
                    ˋ.setAccessible(true);
                } catch (Throwable e) {
                    Log.i("PopupWindowCompatApi21", "Could not fetch mOverlapAnchor field from PopupWindow", e);
                }
                ˊ = true;
            }
            if (ˋ != null) {
                try {
                    ˋ.set(popupWindow, Boolean.valueOf(z));
                } catch (Throwable e2) {
                    Log.i("PopupWindowCompatApi21", "Could not set overlap anchor field in PopupWindow", e2);
                }
            }
        }
    }

    public static void ˎ(@NonNull PopupWindow popupWindow, int i) {
        if (VERSION.SDK_INT >= 23) {
            popupWindow.setWindowLayoutType(i);
            return;
        }
        if (!ˎ) {
            try {
                ॱ = PopupWindow.class.getDeclaredMethod("setWindowLayoutType", new Class[]{Integer.TYPE});
                ॱ.setAccessible(true);
            } catch (Exception e) {
            }
            ˎ = true;
        }
        if (ॱ != null) {
            try {
                ॱ.invoke(popupWindow, new Object[]{Integer.valueOf(i)});
            } catch (Exception e2) {
            }
        }
    }
}
